import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../utils/xh_styles.dart';
import '../../../../utils/xin_he_image.dart';
import '../../models/xin_he_goods_model.dart';
import 'xin_he_pay_success_logic.dart';

class XinHePaySuccessPage extends StatelessWidget {
  XinHePaySuccessPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHePaySuccessLogic());
  final state = Get.find<XinHePaySuccessLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: (){
              Get.back();
            },
            icon: Container(
              padding: const EdgeInsets.only(left: 7),
              alignment: Alignment.centerLeft,
              child: const XinHeAssetImage(
                'assets/images/home/app_back_3.png',
                width: 9.5,
                height: 17,
                fit: BoxFit.cover,),
            )
        ),
        backgroundColor: Colors.white,
        shadowColor: Colors.transparent,
        title: Text(logic.loading.value == 1?'支付成功':'支付查询中',style: TextStyle(color:XinHeColor('#222222'),fontSize: 17,fontWeight: FontWeight.w600)),
        centerTitle: true,
      ),
      body: logic.loading.value ==1
          ? Column(
        children: [
          const SizedBox(height: 50,),
          Container(
            height: 76,
            margin: const EdgeInsets.symmetric(horizontal: 15,vertical: 10),
            padding: const EdgeInsets.symmetric(horizontal: 15),
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(7)),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('您已支付成功！',style: TextStyle(color: XinHeStyle.mainBalckFontColor,fontSize: 15,fontWeight: FontWeight.w500),),
                Text('商家会尽快为您发货，请留意物流信息。',style: TextStyle(color: XinHeColor('#555555'),fontSize: 13,fontWeight: FontWeight.w500),)
              ],),),

          Container(
            padding: const EdgeInsets.symmetric(horizontal: 15),
            margin: EdgeInsets.symmetric(horizontal: 15),
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(7)),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                const SizedBox(height: 10,),
                Text('订单信息',style: TextStyle(color: XinHeStyle.mainBalckFontColor,fontSize: 14,fontWeight: FontWeight.w500),),
                SizedBox(height: 8,),
                Text('订单编号： ${logic.orderModel.value.code}',style: TextStyle(color: XinHeColor('#666666'),fontSize: 12,fontWeight: FontWeight.w500),),
                SizedBox(height: 5,),
                Text('支付时间：${logic.orderModel.value.payTime}',style: TextStyle(color: XinHeColor('#666666'),fontSize: 12,fontWeight: FontWeight.w500),),

                // _goodsItemView(XinHeGoodsModel(),0),

              ],),)
        ],)
          : Column(
        children: [
          const SizedBox(height: 50,),
          Container(
            height: 76,
            margin: const EdgeInsets.symmetric(horizontal: 15,vertical: 10),
            padding: const EdgeInsets.symmetric(horizontal: 15),
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(7)),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('您的支付状态正在查询中，请稍后...',style: TextStyle(color: XinHeStyle.mainBalckFontColor,fontSize: 15,fontWeight: FontWeight.w500),),
                // Text('商家会尽快为您发货，请留意物流信息。',style: TextStyle(color: XinHeColor('#555555'),fontSize: 13,fontWeight: FontWeight.w500),)
              ],),),

         logic.orderModel.value.id != null?  Container(
            padding: const EdgeInsets.symmetric(horizontal: 15),
            margin: const EdgeInsets.symmetric(horizontal: 15),
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(7)),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                const SizedBox(height: 10,),
                Text('订单信息',style: TextStyle(color: XinHeStyle.mainBalckFontColor,fontSize: 14,fontWeight: FontWeight.w500),),
                SizedBox(height: 8,),
                Text('订单编号： ${logic.orderModel.value.code}',style: TextStyle(color: XinHeColor('#666666'),fontSize: 12,fontWeight: FontWeight.w500),),
                SizedBox(height: 5,),
                Text('下单时间：${logic.orderModel.value.createTime}',style: TextStyle(color: XinHeColor('#666666'),fontSize: 12,fontWeight: FontWeight.w500),),


              ],),):Container()
        ],),
    ));
    ;
  }


  Widget _goodsItemView(XinHeGoodsModel model,int index){
    return Stack(
      children: [
        Container(
          color: Colors.white,
          width: Get.width-30,
          height: 120,

          child:  Row(
            children: [

              const Padding(
                padding:  EdgeInsets.only(left: 0,top: 15,right: 15,bottom: 15),
                child: XinHeAssetImage('assets/images/home/tmp.png',width: 80,height: 80,fit: BoxFit.fill,),
              ),

              ///描述与价格数量
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  SizedBox(
                      width:Get.width-30-80-30-15,
                      child: Text('一级冷榨有机野山茶籽油500ML级冷榨有机野iii',maxLines: 2,softWrap: true,style: TextStyle(color: XinHeColor('#222222'),fontSize: 14,fontWeight: FontWeight.w500),)
                  ),
                  const SizedBox(height: 20,),



                  SizedBox(
                    width:Get.width-30-80-30-15,
                    height: 23,
                    child: Row(
                      children: [

                        RichText(
                            text: TextSpan(children: [
                              ///￥
                              TextSpan(
                                text: '￥',
                                style: TextStyle(
                                  color: XinHeColor('#E84128'),
                                  fontSize: 9,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),

                              ///
                              TextSpan(
                                text: '${model.price}',
                                style: TextStyle(
                                  color: XinHeColor('#E84128'),
                                  fontSize: 16,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),

                            ]
                            )),
                        const Spacer(),

                        Text('x${model.count}',style: TextStyle(color: XinHeColor('#8B9191'), fontSize: 12, fontWeight: FontWeight.w500,)
                        ),
                        const SizedBox(width: 0,)

                      ],
                    ),
                  )

                ],)


            ],
          ),
        ),

        Positioned(
          bottom: 0,
          right: 15,
          child: Container(
            width: Get.width-30-30,
            color: XinHeColor('#E7EEEE'),
            height: 0.5,),
        )

      ],
    );
  }

}
